package com.example.grade;

public class Demo {
    public static void main(String[] args) {
        GradeManager mgr = new GradeManager();

        /* 初始化数据 */
        Student s1 = new Student("2021001", "张三", "CS2101");
        Student s2 = new Student("2021002", "李四", "CS2101");
        Course  c1 = new Course("CS101", "程序设计", 4);
        Course  c2 = new Course("MA101", "高等数学", 5);
        Course  c3 = new Course("EN101", "英语", 2);

        mgr.addStudent(s1); mgr.addStudent(s2);
        mgr.addCourse(c1);  mgr.addCourse(c2); mgr.addCourse(c3);

        mgr.addGrade(new Grade(s1, c1, 92));
        mgr.addGrade(new Grade(s1, c2, 85));
        mgr.addGrade(new Grade(s1, c3, 78));
        mgr.addGrade(new Grade(s2, c1, 59)); // 挂科示例

        /* 查询 & 打印 */
        mgr.printTranscript("2021001");
        System.out.println("----------------------");
        mgr.printTranscript("2021002");

        /* 异常演示 */
        try {
            new Grade(s1, c3, 105); // 触发异常
        } catch (ScoreRangeException e) {
            System.out.println("捕获异常: " + e.getMessage());
        }
    }
}